package com.qfjy.config.example3;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ScanPayConfig {
    /**
     * 1、定义交换机
     * 2、分别定义队列
     * 3、交换机和队列进行绑定（路由key)
     */
    /**
     * #TODO 1、定义交换机
     * @return
     */
    @Bean
    public DirectExchange scanPayDirectExchange(){

        return new DirectExchange("scanPayDirectExchange");
    }

    /**
     * #TODO  2、分别定义队列
     */
    @Bean
    public Queue weixinScanPayQueue(){
        return new Queue("weixinScanPayQueue");
    }
    @Bean
    public Queue zhifubaoScanPayQueue(){
        return new Queue("zhifubaoScanPayQueue");
    }
    /**
     * #TODO 3、交换机和队列进行绑定（路由key)
     */
    @Bean
    public Binding bindWeixinQueueDirectExchange( Queue weixinScanPayQueue,DirectExchange scanPayDirectExchange){
        return BindingBuilder.bind(weixinScanPayQueue).to(scanPayDirectExchange).with("weixin");
    }

    @Bean
    public Binding bindZhifubaoQueueDirectExchange( Queue zhifubaoScanPayQueue,DirectExchange scanPayDirectExchange){
        return BindingBuilder.bind(zhifubaoScanPayQueue).to(scanPayDirectExchange).with("zhifubao");
    }
}
